/* 封装inherit函数 */
function inherit(Child, Parent) {
  Object.setPrototypeOf(Child.prototype, Parent.prototype)
}


//普通会员的构造函数
function User(username, password) {
  this.username = username;
  this.password = password;
}


User.prototype.playFreeVideo = function () {
  console.log('观看免费视频')
}


/* 处理构造器内部的重复 */
function VIPUser(username, password, expires) {
  // this.username = username;
  // this.password = password;
  User.call(this, username, password)
  this.expires = expires
}

/* 把vipUser的原型设置指向User的原型即可 */
inherit(VIPUser, User)


VIPUser.prototype.playPayVideo = function () {
  console.log('观看付费视频')
}

var vip = new VIPUser('abc', '123', '2022-10-01');
vip.playFreeVideo()